<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class jQuickForm_Element_Slider extends HTML_QuickForm2_Element_InputText {

    public $slider_min=null;
    public $slider_max=null;
    public $slider_step=null;

    public function render(HTML_QuickForm2_Renderer $renderer){
//        $renderer = new HTML_QuickForm2_Renderer_Default();
        $renderer->setTemplateForClass(strtolower(get_class($this)),'<div class="jqf_row">
        <label for="{id}" class="jqf_element"><qf:required><span class="required">* </span></qf:required>{label}</label>
        <div id="{id}_jqfslider" class="jqfslider"></div>
        <div class="jqf_slider_header">

        {comment}{element}<div class="clear"></div></div>
        </div>');
        jQuickForm::js()->needJquery();
        jQuickForm::js()->needJqueryUi();
        jQuickForm::js()->addJsOnload('
    jQuery("#'.$this->getId().'").change(function(){
        jQuery("#'.$this->getId().'_jqfslider").slider( "value" , jQuery(this).val() );
    });
    jQuery("#'.$this->getId().'_jqfslider").slider({
		min: '.$this->slider_min.',
		max: '.$this->slider_max.',
		step: '.$this->slider_step.',
		value: '.floatval($this->getValue()).',
		slide: function(event, ui) {
			jQuery("#'.$this->getId().'").val(ui.value);
		},
		change: function(event, ui) {
			jQuery("#'.$this->getId().'").val(ui.value);
		}
	});
');
        return parent::render($renderer);
    }

}
?>